function gray=rgb2gray( rgb )
% gray = rgb2gray( rgb ) - converst rbg image to grayscale

% calculate luminance channel
luminance = uint8( sum( rgb, 3 ) / 3 );

% create rgb image from luminance
result(:,:,1) = luminance;
result(:,:,2) = luminance;
result(:,:,3) = luminance;

gray = result;
